home *** CD-ROM | disk | FTP | other *** search
- Path: global.gc.net!sourcebbs!david.mohorn
- From: david.mohorn@sourcebbs.com (DAVID MOHORN)
- Newsgroups: comp.lang.c
- Subject: Re: COLLEGE PROFESSORS! #
- Message-ID: <8BEE4D1.02C700325C.uuout@sourcebbs.com>
- Date: Thu, 18 Apr 96 20:33:00 -0500
- Distribution: world
- Organization: SelectiveSourceBBS VirginiaBeach (804)471 6776
- Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
- References: <Pine.A32.3.91.960417134130.26474G-100000@red.weeg.uiowa.edu
- X-Newsreader: PCBoard Version 15.22
- X-Mailer: PCBoard/UUOUT Version 1.20
-
- RN>> The instructors philosophy is to make it more "readable" and keep it as
- >> structured as possible! As if structured programming was the only way
- >> to accomplish this task. He also stated that nested ifs make the code
- >> harder to read. He also stated that there is no arm in wasting a
- >> few milliseconds doing the extra conditions, since it won't be
- >> noticeable anyway.
-
- RN> This is a perfectly valid approach, and a common one. I daresay that
- >he's doubly smart for insisting on a structured programming approach in a
- >language that has traditionally encouraged spaghetti code.
- >There _is_ no harm is wasting a few microseconds, if it makes the code
- >clearer (which avoids wasting a few days, or weeks, or months spent
- >debugging or maintaining or even trying to comprehend the code). And if the
- >compiler's smart enough, it might produce efficient code for the
- >professor's approach. I share my Prolog professor's confusion over
- >people being in such a hurry to get the wrong answer.
-
- I agree. There are times when writing such code that readability is
- more important than efficiency, but the logic of this code was
- illogical, verified data that was already identified as being invalid,
- so why continue scanning the data... I think a construct such as:
-
- if(whatever) abort=1
- else process_data
-
- if(whatever) abort=1
- else process_data
-
- if(whatever) abort=1
- else process_data
-
- if(abort==1) return ERROR
-
- is more confusing than a simple:
-
- if(whatever) return ERROR
- else process_data
-
- if(whatever) return ERROR
- else process_data
-
- if(whatever) return ERROR
- else process_data
-
- The former example still checked the last two ifs, even if the first if
- set the variable abort to the value 1. The last latter example,
- however, is much faster and easier to read.
-
- RN>> I retorted his remark and said it would on a multitasking system where
- >> every cycle counts! If I were validating 10,000 data items, example 1
- >> would take a considerable amount of time longer than example 2!
-
- RN> In this day and age of Alphas, Pentiums, PowerPCs, MIPSs, and home
- >computers with 24MB of interleaved DIMM RAM, which multitasking systems are
- >those? Do you honestly believe that Windows code squeezes out every
- >microsecond? Besides, if you were so concerned about speed, you'd be
- >writing in assembly, FORTRAN or C and making calls to the API at the
- >lowest possible level. And you'd _still_ be writing structured code, if you
- >ever wanted to make sense of your program again.
- > Dev platforms like Delphi, Forte and VB allow the programmer to work at a
- >very high level. It is _assumed_ that clarity and rapid
- >application development are the top priorities at that level.
-
- VisualBASIC isn't all that bad... And this type of mentality is why we
- have bloated, inefficient code today. I have excellent games for my
- TRS-80 Model IV that fits on a 360K diskette--monochrome graphics and
- sound... Now you buy games that are 2 CD-ROMS!
-
- RN>> Does anyone else have any opinions or horror stories?
-
- RN> My horror story is one word long: BASIC.
-
- I disagree.
- ---
- * QMPro 1.53 * main(int c){void *f[10];c=0;while(f)f[c++]=tmpfile();}
-
-
- ---
- This message originated from: ---------- Selective Source BBS
- ------- Virginia Beach, Virginia
- ----- (804) 471 6776
-